﻿namespace System
{
    using System;
    using System.ComponentModel;
    using System.Threading;

    public class ActionResult : INotifyPropertyChanged
    {
        private DateTime _EndTime;
        private string _Message;
        private object _Result;
        private DateTime _StartTime;
        private ActionStatus _Status;
        private string _TaskName;
        private PropertyChangedEventHandler _PropertyChanged;

        public event PropertyChangedEventHandler PropertyChanged
        {
            add
            {
                PropertyChangedEventHandler handler2;
                PropertyChangedEventHandler propertyChanged = this._PropertyChanged;
                do
                {
                    handler2 = propertyChanged;
                    PropertyChangedEventHandler handler3 = (PropertyChangedEventHandler) Delegate.Combine(handler2, value);
                    propertyChanged = Interlocked.CompareExchange<PropertyChangedEventHandler>(ref this._PropertyChanged, handler3, handler2);
                }
                while (propertyChanged != handler2);
            }
            remove
            {
                PropertyChangedEventHandler handler2;
                PropertyChangedEventHandler propertyChanged = this._PropertyChanged;
                do
                {
                    handler2 = propertyChanged;
                    PropertyChangedEventHandler handler3 = (PropertyChangedEventHandler) Delegate.Remove(handler2, value);
                    propertyChanged = Interlocked.CompareExchange<PropertyChangedEventHandler>(ref this._PropertyChanged, handler3, handler2);
                }
                while (propertyChanged != handler2);
            }
        }

        public ActionResult()
        {
            this.Status = ActionStatus.Ready;
        }

        private void RaisePropertyChanged(string prop)
        {
            if (this._PropertyChanged != null)
            {
                this._PropertyChanged(this, new PropertyChangedEventArgs(prop));
            }
        }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime
        {
            get
            {
                return this._EndTime;
            }
            set
            {
                if (this._EndTime != value)
                {
                    this._EndTime = value;
                    this.RaisePropertyChanged("EndTime");
                }
            }
        }
        /// <summary>
        /// 消息
        /// </summary>

        public string Message
        {
            get
            {
                return this._Message;
            }
            set
            {
                if (this._Message != value)
                {
                    this._Message = value;
                    this.RaisePropertyChanged("Message");
                }
            }
        }
        /// <summary>
        /// 任务结果
        /// </summary>
        public object Result
        {
            get
            {
                return this._Result;
            }
            set
            {
                if (this._Result != value)
                {
                    this._Result = value;
                    this.RaisePropertyChanged("Result");
                }
            }
        }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime
        {
            get
            {
                return this._StartTime;
            }
            set
            {
                if (this._StartTime != value)
                {
                    this._StartTime = value;
                    this.RaisePropertyChanged("StartTime");
                }
            }
        }
        /// <summary>
        /// 状态
        /// </summary>

        public ActionStatus Status
        {
            get
            {
                return this._Status;
            }
            set
            {
                if (this._Status != value)
                {
                    this._Status = value;
                    this.RaisePropertyChanged("Status");
                }
            }
        }
        /// <summary>
        /// 任务名称
        /// </summary>

        public string TaskName
        {
            get
            {
                return this._TaskName;
            }
            set
            {
                if (this._TaskName != value)
                {
                    this._TaskName = value;
                    this.RaisePropertyChanged("TaskName");
                }
            }
        }
    }
}

